<?php require('connections/con_gl.php'); ?>
<?php
cekAkses($_SESSION[akses],"PJ-2");
mysql_select_db($database_con_gl, $con_gl);
$query_kontak = "SELECT id, nama, type FROM gl_kontak where gl_kontak.type <>'Supplier' ORDER BY type, nama ASC";
$kontak = mysql_query($query_kontak, $con_gl) or die(mysql_error());
$row_kontak = mysql_fetch_assoc($kontak);
$totalRows_kontak = mysql_num_rows($kontak);

// ---
mysql_select_db($database_con_gl, $con_gl);
$query_gudang = "SELECT id, gudang FROM gl_gudang";
if(!strstr($_SESSION[akses],'A-1-4')) {
	$query_gudang .= " where id='$_SESSION[lokasi]'";
}
$query_gudang .=" ORDER BY gudang ASC";
$gudang = mysql_query($query_gudang, $con_gl) or die(mysql_error());
$row_gudang = mysql_fetch_assoc($gudang);
$totalRows_gudang = mysql_num_rows($gudang);

mysql_select_db($database_con_gl, $con_gl);
$query_satuan = "SELECT id, satuan FROM gl_satuan ORDER BY satuan ASC";
$satuan = mysql_query($query_satuan, $con_gl) or die(mysql_error());
$row_satuan = mysql_fetch_assoc($satuan);
$totalRows_satuan = mysql_num_rows($satuan);

mysql_select_db($database_con_gl, $con_gl);
$query_kelom = "SELECT id, kelompok FROM gl_kelompok ORDER BY kelompok ASC";
$kelom = mysql_query($query_kelom, $con_gl) or die(mysql_error());
$row_kelom = mysql_fetch_assoc($kelom);
$totalRows_kelom = mysql_num_rows($kelom);

mysql_select_db($database_con_gl, $con_gl);
$query_klas = "SELECT kd, klasifikasi, keterangan, neraca, ruglab, tipe FROM gl_klas where tipe = 2 ORDER BY kd,klasifikasi ASC";
$klas = mysql_query($query_klas, $con_gl) or die(mysql_error());
$row_klas = mysql_fetch_assoc($klas);
$totalRows_klas = mysql_num_rows($klas);

mysql_select_db($database_con_gl, $con_gl);
$query_def_ak = "SELECT gl_company.a_kas FROM gl_company";
$def_ak = mysql_query($query_def_ak, $con_gl) or die(mysql_error());
$row_def_ak = mysql_fetch_assoc($def_ak);
$totalRows_def_ak = mysql_num_rows($def_ak);

$colname_edit = "-1";
if (isset($_GET['noreferensi'])) {
  $colname_edit = (get_magic_quotes_gpc()) ? $_GET['noreferensi'] : addslashes($_GET['noreferensi']);
}
mysql_select_db($database_con_gl, $con_gl);
$query_edit = sprintf("SELECT * FROM gl_rtrans WHERE no_ref = '$_GET[noreferensi]'", $colname_edit);
$edit = mysql_query($query_edit, $con_gl) or die(mysql_error());
$row_edit = mysql_fetch_assoc($edit);
$totalRows_edit = mysql_num_rows($edit);

mysql_select_db($database_con_gl, $con_gl);
$query_getidh = "SELECT gl_trans.id, gl_trans.akun, gl_trans.total FROM gl_trans WHERE gl_trans.no_ref='$_REQUEST[noreferensi]' AND gl_trans.transaksi LIKE '%%Piutang%%'";
$getidh = mysql_query($query_getidh, $con_gl) or die(mysql_error());
$row_getidh = mysql_fetch_assoc($getidh);
$totalRows_getidh = mysql_num_rows($getidh);

mysql_select_db($database_con_gl, $con_gl);
$query_getidh2 = "SELECT gl_trans.id, gl_trans.total FROM gl_trans WHERE gl_trans.no_ref='$_REQUEST[noreferensi]' AND gl_trans.transaksi LIKE '%%Pembelian%%'";
$getidh2 = mysql_query($query_getidh2, $con_gl) or die(mysql_error());
$row_getidh2 = mysql_fetch_assoc($getidh2);
$totalRows_getidh2 = mysql_num_rows($getidh2);

mysql_select_db($database_con_gl, $con_gl);
$query_tr = "SELECT gl_trans.id, gl_trans.total, gl_trans.jumlah, gl_trans.hargasatuan, gl_trans.transaksi, gl_trans.diskon, gl_akun.akun, gl_akun.id as akun_id, gl_barang.id as brg_id, gl_barang.barang, gl_satuan.satuan FROM gl_trans, gl_akun, gl_barang, gl_satuan WHERE gl_akun.id = gl_trans.akun AND gl_barang.id = gl_trans.barang AND gl_satuan.id = gl_trans.satuan AND gl_trans.no_ref='$_GET[noreferensi]' AND gl_trans.pos='K' ORDER BY gl_trans.id desc";
$tr = mysql_query($query_tr, $con_gl) or die(mysql_error());
$row_tr = mysql_fetch_assoc($tr);
$totalRows_tr = mysql_num_rows($tr);

mysql_select_db($database_con_gl, $con_gl);
$query_getbiaya = "SELECT distinct gl_rtrans.akbiaya, gl_trans.id, gl_trans.total FROM gl_rtrans, gl_trans WHERE gl_trans.no_ref='$_GET[noreferensi]' AND gl_trans.akun=gl_rtrans.akbiaya";
$getbiaya = mysql_query($query_getbiaya, $con_gl) or die(mysql_error());
$row_getbiaya = mysql_fetch_assoc($getbiaya);
$totalRows_getbiaya = mysql_num_rows($getbiaya);

mysql_select_db($database_con_gl, $con_gl);
$query_getpajak = "SELECT distinct gl_rtrans.akpjk, gl_trans.id, gl_trans.total FROM gl_rtrans, gl_trans WHERE gl_trans.no_ref='$_GET[noreferensi]' AND gl_trans.akun=gl_rtrans.akpjk";
$getpajak = mysql_query($query_getpajak, $con_gl) or die(mysql_error());
$row_getpajak = mysql_fetch_assoc($getpajak);
$totalRows_getpajak = mysql_num_rows($getpajak);

mysql_select_db($database_con_gl, $con_gl);
$query_getbyr = "SELECT gl_trans.id, gl_trans.total, gl_trans.akun FROM gl_trans WHERE gl_trans.no_ref='$_GET[noreferensi]' AND gl_trans.transaksi LIKE'%%Pembayaran%%'";
$getbyr = mysql_query($query_getbyr, $con_gl) or die(mysql_error());
$row_getbyr = mysql_fetch_assoc($getbyr);
$totalRows_getbyr = mysql_num_rows($getbyr);

mysql_select_db($database_con_gl, $con_gl);
$query_klashut = "SELECT kd, klasifikasi, keterangan, neraca, ruglab, tipe FROM gl_klas where tipe = 6 ORDER BY kd,klasifikasi ASC";
$klashut = mysql_query($query_klashut, $con_gl) or die(mysql_error());
$row_klashut = mysql_fetch_assoc($klashut);
$totalRows_klashut = mysql_num_rows($klashut);

mysql_select_db($database_con_gl, $con_gl);
$query_salesmen = "SELECT gl_kontak.id, gl_kontak.nama FROM gl_kontak WHERE gl_kontak.type='Karyawan' order by nama";
$salesmen = mysql_query($query_salesmen, $con_gl) or die(mysql_error());
$row_salesmen = mysql_fetch_assoc($salesmen);
$totalRows_salesmen = mysql_num_rows($salesmen);

mysql_select_db($database_con_gl, $con_gl);
$query_getkakun = "SELECT gl_trans.akun, gl_klas.klasifikasi, gl_akun.klasifikasi as klas_id FROM gl_trans, gl_klas, gl_akun WHERE gl_trans.no_ref='$_GET[noreferensi]' AND gl_trans.pos='K' AND gl_klas.tipe=2 AND gl_akun.klasifikasi = gl_klas.kd AND gl_trans.akun = gl_akun.id";
$getkakun = mysql_query($query_getkakun, $con_gl) or die(mysql_error());
$row_getkakun = mysql_fetch_assoc($getkakun);
$totalRows_getkakun = mysql_num_rows($getkakun);

mysql_select_db($database_con_gl, $con_gl);
$query_gethutang = "SELECT distinct gl_rtrans.akpjk, gl_trans.id, gl_trans.total FROM gl_rtrans, gl_trans WHERE gl_trans.no_ref='$_GET[noreferensi]' AND gl_trans.akun='$row_getidh[akun]'";
$gethutang = mysql_query($query_gethutang, $con_gl) or die(mysql_error());
$row_gethutang = mysql_fetch_assoc($gethutang);
$totalRows_gethutang = mysql_num_rows($gethutang);

mysql_select_db($database_con_gl, $con_gl);
$query_klasbeban = "SELECT * FROM gl_klas WHERE gl_klas.tipe=10";
$klasbeban = mysql_query($query_klasbeban, $con_gl) or die(mysql_error());
$row_klasbeban = mysql_fetch_assoc($klasbeban);
$totalRows_klasbeban = mysql_num_rows($klasbeban);

mysql_select_db($database_con_gl, $con_gl);
$query_klasbeban2 = "SELECT * FROM gl_klas WHERE gl_klas.tipe=9";
$klasbeban2 = mysql_query($query_klasbeban2, $con_gl) or die(mysql_error());
$row_klasbeban2 = mysql_fetch_assoc($klasbeban2);
$totalRows_klasbeban2 = mysql_num_rows($klasbeban2);

$totdeb = 0;
$totkre = 0;
?>
<link rel="stylesheet" type="text/css" href="css/ui.datepicker.css"/>
<script type="text/javascript" src="js/ajax_data.js"></script>
<script type="text/javascript" src="js/ui.datepicker.js"></script>
<script type="text/javascript">
<!--
$(function()
      {
        $('.calendar').datepicker({
            appendText : "yyyy/mm/dd",
            dateFormat : 'yy/mm/dd'
          });
      });
</script>
<script type="text/javascript">
<!--
$(document).ready(function() {

	$().ajaxStart(function() {
		$('#loading').show();
		$('#result').hide();
	}).ajaxStop(function() {
		$('#loading').hide();
		$('#result').fadeIn('slow');
	});

	$('#shipping').submit(function() {
		$.ajax({
			type: 'POST',
			url: $(this).attr('action'),
			data: $(this).serialize(),
			success: function(data) {
				$('#result').html(data);
			}
		})
		return false;
	});
  $('#result').click(function(){
  $(this).hide();
  });
})
</script>
<div id="loading" style="display:none;"><img src="images/loading.gif" alt="loading..." /></div>
<div id="result" style="display:none;"></div>
<h1>Pengiriman Penjualan</h1>
<form action="proses/pengirimanbarangpenjualan.php?act=shipping" method="post" name="shipping" id="shipping">
  <table width="98%" border="0" align="center" cellpadding="5" cellspacing="0" class="datatable">
    <tr>
      <td width="12%" align="right">Akun Kas : </td>
      <td width="30%">
        <label>
          <select name="akun" id="akun" onfocus="this.blur();">
            <?php
do {  
?>
            <?php
mysql_select_db($database_con_gl, $con_gl);
$query_akun = "SELECT id, akun, klasifikasi, keterangan FROM gl_akun where klasifikasi = '$row_klas[kd]' ORDER BY id,akun ASC";
$akun = mysql_query($query_akun, $con_gl) or die(mysql_error());
$row_akun = mysql_fetch_assoc($akun);
$totalRows_akun = mysql_num_rows($akun);
?>
            <option value="" style="background:#EEEEEE; font-weight:bold;"><?php echo $row_klas['klasifikasi'];?></option>
            <?php do { ?>
            <option value="<?php echo $row_akun['id']?>" <?php if($row_akun[id]==$row_getkakun[akun]) { ?>selected="selected"<?php } ?>>-<?php echo $row_akun['akun']?></option>
            <?php } while ($row_akun = mysql_fetch_assoc($akun));?>
            <?php
} while ($row_klas = mysql_fetch_assoc($klas));
  $rows = mysql_num_rows($klas);
  if($rows > 0) {
      mysql_data_seek($klas, 0);
	  $row_klas = mysql_fetch_assoc($klas);
  }
?>
          </select>
        </label>
      </td>
      <td width="11%" align="right">Akun Piutang : </td>
      <td width="47%"><div id="tipetrans">
        <label>
          <?php if($row_getidh['akun']<>'') { ?>
          <select name="akunkredit" id="akunkredit" onfocus="this.blur();">
            <?php
do {  
?>
            <?php
mysql_select_db($database_con_gl, $con_gl);
$query_akun = "SELECT id, akun, klasifikasi, keterangan FROM gl_akun where klasifikasi = '$row_klashut[kd]' ORDER BY id,akun ASC";
$akun = mysql_query($query_akun, $con_gl) or die(mysql_error());
$row_akun = mysql_fetch_assoc($akun);
$totalRows_akun = mysql_num_rows($akun);
?>
            <option value="" style="background:#EEEEEE; font-weight:bold;" title="<?php echo $row_klas['keterangan'];?><?php if($row_klashut['neraca'] <> 0) { ?>, tipe : <?php if($row_klashut['neraca']==1) { echo "Aktiva";}else if($row_klashut['neraca']==2) { echo "Pasiva";} ?><?php } ?>"><?php echo $row_klashut['kd']." - ";echo $row_klashut['klasifikasi'];?></option>
            <?php do { ?>
            <option value="<?php echo $row_akun['id']?>" title="<?php echo $row_akun['keterangan']?><?php if($row_klashut['ruglab'] <> 0) { ?>, tipe : <?php if($row_klashut['ruglab']==1) { echo "Pendapatan Usaha";}else if($row_klashut['ruglab']==2) { echo "Beban Usaha";} ?><?php } ?>" <?php if($row_akun[id]==$row_getidh['akun']) { ?>selected="selected"<?php } ?>>----- <?php echo $row_akun['id']." - ";echo $row_akun['akun']?></option>
            <?php } while ($row_akun = mysql_fetch_assoc($akun));?>
            <?php
} while ($row_klashut = mysql_fetch_assoc($klashut));
  $rows = mysql_num_rows($klashut);
  if($rows > 0) {
      mysql_data_seek($klashut, 0);
	  $row_klashut = mysql_fetch_assoc($klashut);
  }
?>
          </select>
          <?php }else{ ?>
          <input name="akunkredit" type="hidden" id="akunkredit" value="<?php echo $row_getidh['akun']; ?>" />
          <?php } ?>
          </label>
        <label>
          <?php
		$zx = $ntot - $row_getidh['total'];
		?>
          <input name="tipetrans" type="radio" onchange="if(this.checked) { cektipetrans(this.value);}" value="Tunai" <?php if($row_getidh['akun']=='') { ?>checked="checked"<?php } ?> disabled="disabled"/>
          Tunai</label>
        <label>
          <input type="radio" name="tipetrans" value="Kredit" onchange="if(this.checked) { cektipetrans(this.value);}" <?php if($row_getidh['akun']<>'') { ?>checked="checked"<?php } ?> disabled="disabled"/>
          Kredit</label>
        <input name="akunkredit" type="hidden" id="akunkredit" value="<?php echo $row_getidh['akun']; ?>" />
        <?php //echo $totalRows_hutang;?>
      </div></td>
    </tr>
    <tr>
      <td align="right" valign="top">No. Referensi :</td>
      <td valign="top"><label>
        <input name="noreferensi" type="text" id="noreferensi" value="<?php echo $row_edit['no_ref']; ?>" size="20" maxlength="20" onfocus="this.blur();"/>
      </label></td>
      <td align="right" valign="top">Gudang : </td>
      <td valign="top"><label>
        <select name="gudang" id="gudang" onfocus="this.blur();">
          <?php
do {  
?>
          <option value="<?php echo $row_gudang['id'];?>" <?php if($row_gudang['id']==$row_edit['gudang']) { ?>selected="selected"<?php } ?>><?php echo $row_gudang['gudang']?></option>
          <?php
} while ($row_gudang = mysql_fetch_assoc($gudang));
  $rows = mysql_num_rows($gudang);
  if($rows > 0) {
      mysql_data_seek($gudang, 0);
	  $row_gudang = mysql_fetch_assoc($gudang);
  }
?>
        </select>
      </label></td>
    </tr>
    <tr>
      <td align="right" valign="top">Tanggal :<br />
      <br />
      Tanggal Kirim : </td>
      <td valign="top"><label>
        <input name="tanggal" type="text" id="tanggal" value="<?php echo $row_edit['tgl']; ?>" size="20" maxlength="15" onfocus="this.blur();"/>
      </label><br />
      <br />
      <label>
      <input name="kirim" type="text" class="calendar" id="kirim" value="<?php echo date("Y/m/d"); ?>" size="20" maxlength="15" onfocus="this.blur();"/>
      </label></td>
      <td align="right" valign="top">Jatuh Tempo :</td>
      <td valign="top"><label>
        <input name="jatuhtempo" type="text" class="calendar" id="jatuhtempo" value="<?php echo $row_edit['jatuhtempo']; ?>" size="20" maxlength="15" onfocus="this.blur();"/>
        <input name="id_beli" type="hidden" id="id_beli" value="<?php echo $row_getidh2[id];?>"/>
        <input name="id_hutang" type="hidden" id="id_hutang" value="<?php echo $row_getidh['id']; ?>" />
        <input name="id_biaya" type="hidden" id="id_biaya" value="<?php echo $row_getbiaya['id']; ?>" />
        <input name="idpajak" type="hidden" id="idpajak" value="<?php echo $row_getpajak['id']; ?>" />
        <input name="idbayar" type="hidden" id="idbayar" value="<?php echo $row_getbyr['id']; ?>" />
      </label></td>
    </tr>
    <tr>
      <td align="right" valign="top">Dari :</td>
      <td valign="top"><label>
        <select name="dari" id="dari" style="width:200px;" onchange="setKeterangan(this.value);" onfocus="this.blur();">
          <option value="" <?php if (!(strcmp("", $row_edit['kontak']))) {echo "selected=\"selected\"";} ?>>Pilih Kontak</option>
          <?php
do {  
?>
          <option value="<?php echo $row_kontak['id']?>"<?php if (!(strcmp($row_kontak['id'], $row_edit['kontak']))) {echo "selected=\"selected\"";} ?>><?php echo $row_kontak['nama']?> ( <?php echo $row_kontak['type']; ?> )</option>
          <?php
} while ($row_kontak = mysql_fetch_assoc($kontak));
  $rows = mysql_num_rows($kontak);
  if($rows > 0) {
      mysql_data_seek($kontak, 0);
	  $row_kontak = mysql_fetch_assoc($kontak);
  }
?>
        </select>
      </label></td>
      <td align="right" valign="top">Keterangan :</td>
      <td valign="top"><label>
        <textarea name="keterangan" cols="40" rows="2" id="keterangan" onfocus="this.blur();"><?php echo $row_edit['keterangan']; ?></textarea>
      </label></td>
    </tr>
    <tr>
      <td colspan="4" align="right"><div id="ajaxDiv">
        <table width="100%" border="0" cellspacing="0" cellpadding="5" class="datatable">
          <tr>
            <th width="25%" align="center"><strong>Barang</strong></th>
            <th width="9%" align="center"><strong>Satuan</strong></th>
            <th width="10%" align="center"><strong>Jumlah</strong></th>
            <th width="10%" align="center"><strong>Harga Satuan </strong></th>
            <th width="7%" align="center"><strong>Diskon</strong></th>
            <th width="10%" align="center"><strong>Total</strong></th>
            <th align="center"><strong>Transaksi</strong></th>
            <th width="15%" align="center"><strong>Aksi</strong></th>
          </tr>
          <?php if($totalRows_tr > 0) { ?>
          <?php $ntot = 0; do { ?>
          <tr valign="top" bgcolor="#FFFFFF">
            <td align="center" ><?php echo $row_tr['brg_id']; ?> - <?php echo $row_tr['barang']; ?></td>
            <td align="center" ><?php echo $row_tr['satuan']; ?></td>
            <td align="center" ><?php echo $row_tr['jumlah']; ?></td>
            <td align="right" ><?php echo number_format($row_tr['hargasatuan'],0,',','.').",-"; ?></td>
            <td align="center" ><?php echo $row_tr['diskon']; ?>%</td>
            <td align="right" ><?php echo number_format($row_tr['total'],0,',','.').",-";$ntot += $row_tr['total']; ?></td>
            <td align="center" ><?php echo $row_tr['transaksi']; ?></td>
            <td align="center" ><label>
              <button value="Edit" onclick="ajaxEditFormPembelian(<?php echo $row_tr['id']; ?>);" type="button" class="editbutton" title="Edit Transaksi" disabled="disabled">&nbsp;</button>
              </label>
                  <label>
                  <input name="hapus" type="button" id="hapus" value="&nbsp;" onclick="ajaxManagePembelian('Hapus',<?php echo $row_tr['id']; ?>);" title="Hapus Transaksi" class="deletebutton" disabled="disabled"/>
                  </label></td>
          </tr>
          <?php } while ($row_tr = mysql_fetch_assoc($tr)); ?>
          <?php } ?>
          <tr valign="top">
            <td align="center" >&nbsp;</td>
            <td align="center" >&nbsp;</td>
            <td align="center" >&nbsp;</td>
            <td colspan="2" align="right" >Sub Total  : </td>
            <td align="center" bgcolor="#FFFFFF" ><label>
              <input name="xntotal" type="text" id="xntotal" value="<?php echo intval($ntot);?>" size="10" maxlength="10" onfocus="this.blur();"/>
            </label></td>
            <td align="center" >&nbsp;</td>
            <td align="center" >&nbsp;</td>
          </tr>
          <tr valign="top">
            <td align="center" >&nbsp;</td>
            <td align="center" >&nbsp;</td>
            <td align="center" >&nbsp;</td>
            <td colspan="2" align="right" >Biaya lain : </td>
            <td align="right" bgcolor="#FFFFFF" ><label>
              <input name="biaya" type="text" id="biaya" value="<?php echo $row_getbiaya['total']; ?>" size="10" maxlength="10" onchange="javascript:this.form.ntotal.value = (2*this.form.xntotal.value) - this.form.xntotal.value + (2*this.form.biaya.value) - this.form.biaya.value + (2*this.form.pajak.value) - this.form.pajak.value;this.form.saldohutang.value=this.form.ntotal.value-this.form.bayar.value;" onfocus="this.blur();"/>
            </label></td>
            <td align="left" bgcolor="#FFFFFF" ><label>
              <select name="akunbiaya" id="akunbiaya" onfocus="this.blur();">
                <?php
do {  
?>
                <?php
mysql_select_db($database_con_gl, $con_gl);
$query_akun = "SELECT id, akun, klasifikasi, keterangan FROM gl_akun where klasifikasi = '$row_klasbeban[kd]' ORDER BY id,akun ASC";
$akun = mysql_query($query_akun, $con_gl) or die(mysql_error());
$row_akun = mysql_fetch_assoc($akun);
$totalRows_akun = mysql_num_rows($akun);
?>
                <option value="" style="background:#EEEEEE; font-weight:bold;"><?php echo $row_klasbeban['klasifikasi'];?></option>
                <?php do { ?>
                <option value="<?php echo $row_akun['id']?>" <?php if($row_akun['id'] == $row_getbiaya['akbiaya']) { ?>selected="selected"<?php } ?>>-<?php echo $row_akun['akun']?></option>
                <?php } while ($row_akun = mysql_fetch_assoc($akun));?>
                <?php
} while ($row_klasbeban = mysql_fetch_assoc($klasbeban));
  $rows = mysql_num_rows($klasbeban);
  if($rows > 0) {
      mysql_data_seek($klasbeban, 0);
	  $row_klasbeban = mysql_fetch_assoc($klasbeban);
  }
?>
              </select>
            </label></td>
            <td align="center" >&nbsp;</td>
          </tr>
          <tr valign="top">
            <td align="center" >&nbsp;</td>
            <td align="center" >&nbsp;</td>
            <td align="center" >&nbsp;</td>
            <td colspan="2" align="right" >Pajak :</td>
            <td align="right" bgcolor="#FFFFFF" ><input name="bobot" type="text" id="bobot" value="<?php echo intval($ntot / $row_getpajak['total'])?>" size="10" maxlength="10" onchange="javascript:if(this.value &lt; 100) { this.form.pajak.value = (this.form.xntotal.value * this.value) / 100;this.form.ntotal.value = (2*this.form.xntotal.value) - this.form.xntotal.value + (2*this.form.biaya.value) - this.form.biaya.value + (2*this.form.pajak.value) - this.form.pajak.value;this.form.saldohutang.value=this.form.ntotal.value-this.form.bayar.value;}else{ this.form.pajak.value = this.value;this.form.ntotal.value = (2*this.form.xntotal.value) - this.form.xntotal.value + (2*this.form.biaya.value) - this.form.biaya.value + (2*this.form.pajak.value) - this.form.pajak.value;this.form.saldohutang.value=this.form.ntotal.value-this.form.bayar.value;}" onfocus="this.blur();"/></td>
            <td align="left" bgcolor="#FFFFFF" >0-99 (%), &gt; 100 (Nilai) </td>
            <td align="center" >&nbsp;</td>
          </tr>
          <tr valign="top">
            <td align="center" >&nbsp;</td>
            <td align="center" >&nbsp;</td>
            <td align="center" >&nbsp;</td>
            <td colspan="2" align="right" >&nbsp;</td>
            <td align="right" bgcolor="#FFFFFF" ><label>
              <input name="pajak" type="text" id="pajak" value="<?php echo $row_getpajak['total']; ?>" size="10" maxlength="10" onchange="javascript:this.form.ntotal.value = (2*this.form.xntotal.value) - this.form.xntotal.value + (2*this.form.biaya.value) - this.form.biaya.value + (2*this.form.pajak.value) - this.form.pajak.value;" onfocus="this.blur();"/>
            </label></td>
            <td align="left" bgcolor="#FFFFFF" ><label>
              <select name="akunpajak" id="akunpajak" onfocus="this.blur();">
                <?php
do {  
?>
                <?php
mysql_select_db($database_con_gl, $con_gl);
$query_akun = "SELECT id, akun, klasifikasi, keterangan FROM gl_akun where klasifikasi = '$row_klasbeban2[kd]' ORDER BY id,akun ASC";
$akun = mysql_query($query_akun, $con_gl) or die(mysql_error());
$row_akun = mysql_fetch_assoc($akun);
$totalRows_akun = mysql_num_rows($akun);
?>
                <option value="" style="background:#EEEEEE; font-weight:bold;"><?php echo $row_klasbeban2['klasifikasi'];?></option>
                <?php do { ?>
                <option value="<?php echo $row_akun['id']?>" <?php if($row_akun['id'] == $row_getpajak['akpjk']) { ?>selected="selected"<?php } ?>>-<?php echo $row_akun['akun']?></option>
                <?php } while ($row_akun = mysql_fetch_assoc($akun));?>
                <?php
} while ($row_klasbeban2 = mysql_fetch_assoc($klasbeban2));
  $rows = mysql_num_rows($klasbeban2);
  if($rows > 0) {
      mysql_data_seek($klasbeban2, 0);
	  $row_klasbeban2 = mysql_fetch_assoc($klasbeban2);
  }
?>
              </select>
            </label></td>
            <td align="center" >&nbsp;</td>
          </tr>
          <tr valign="top">
            <td align="center" >&nbsp;</td>
            <td align="center" >&nbsp;</td>
            <td align="center" >&nbsp;</td>
            <td colspan="2" align="right" >Total : </td>
            <td align="right" bgcolor="#FFFFFF" ><label>
              <input name="ntotal" type="text" id="ntotal" value="<?php $subt = intval($ntot + $row_getbiaya[total] + $row_getpajak[total]); echo $subt;?>" size="10" maxlength="10" onchange="this.form.saldohutang.value=this.value-this.form.bayar.value;" onfocus="this.blur();"/>
            </label></td>
            <td align="left" bgcolor="#FFFFFF" ><input name="payment" type="checkbox" id="payment" value="checkbox" onclick="if(this.checked) { this.form.bayar.value= this.form.ntotal.value;this.form.saldohutang.value=0;}else{ this.form.bayar.value=0;this.form.saldohutang.value=this.form.ntotal.value;}" disabled="disabled"/>
              Cek jika tunai </td>
            <td align="center" >&nbsp;</td>
          </tr>
          <tr valign="top">
            <td align="center" >&nbsp;</td>
            <td align="center" >&nbsp;</td>
            <td align="center" >&nbsp;</td>
            <td colspan="2" align="right" >Bayar / Uang muka : </td>
            <td align="right" bgcolor="#FFFFFF" ><input name="bayar" type="text" id="bayar" value="<?php echo $row_getbyr['total']; ?>" size="10" maxlength="10" onchange="javascript:this.form.saldohutang.value = this.form.ntotal.value-this.form.bayar.value;" onfocus="this.blur();"/></td>
            <td align="left" bgcolor="#FFFFFF" ><label></label>
                  <label></label></td>
            <td align="center" >&nbsp;</td>
          </tr>
          <tr valign="top">
            <td align="left" >Salesmen :
              <label>
                  <select name="salesmen" id="salesmen" onfocus="this.blur();">
                    <?php
do {  
?>
                    <option value="<?php echo $row_salesmen['id']?>"<?php if (!(strcmp($row_salesmen['id'], $row_edit['salesmen']))) {echo "selected=\"selected\"";} ?>><?php echo $row_salesmen['nama']?></option>
                    <?php
} while ($row_salesmen = mysql_fetch_assoc($salesmen));
  $rows = mysql_num_rows($salesmen);
  if($rows > 0) {
      mysql_data_seek($salesmen, 0);
	  $row_salesmen = mysql_fetch_assoc($salesmen);
  }
?>
                  </select>
                </label></td>
            <td align="center" >&nbsp;</td>
            <td align="center" >&nbsp;</td>
            <td colspan="2" align="right" >Saldo Hutang : </td>
            <td align="right" bgcolor="#FFFFFF" ><input name="saldohutang" type="text" id="saldohutang" value="<?php echo $row_gethutang['total']; ?>" size="10" maxlength="10" onfocus="this.blur();"/></td>
            <td align="left" >&nbsp;</td>
            <td align="center" >&nbsp;</td>
          </tr>
        </table>
      </div></td>
    </tr>
    <tr>
      <td align="right">&nbsp;</td>
      <td colspan="3" align="right"><input name="jenis" type="hidden" id="jenis" value="7" />
          <label>
          <input name="Save" type="submit" id="Save" value="Simpan Pengiriman" />
        </label></td>
    </tr>
  </table>
</form>
